package com.wyu.blog.service;

import com.wyu.blog.dao.CommentMapper;
import com.wyu.blog.entity.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {

    @Autowired
    private CommentMapper commentMapper;


    /**
     *
     * @return
     */
    public List<Comment> findAllComment() {
        return commentMapper.selectAllComment();
    }

    public Comment findComment(Integer commentId) {
        return commentMapper.selectComment(commentId);
    }

    public void deleteComment(Integer commentId) {
        commentMapper.deleteCommentById(commentId);
    }

    public List<Comment> findCommentByArticleId1(Integer articleId) {
        return commentMapper.selectCommentById1(articleId);
    }

    public List<Comment> findCommentByArticleId2(Integer articleId) {
        return commentMapper.selectCommentById2(articleId);
    }

    public Integer findCommentNum(Integer articleId) {
        return commentMapper.selectCommentNum(articleId);
    }

    public Integer addComment(Comment comment){
        return commentMapper.insertComment(comment);
    }

    public Integer updateChildComment(Comment comment){
        return commentMapper.updateChildCommentNum(comment);
    }


    public Integer addChildComment(Comment comment){
        return commentMapper.insertChildComment(comment);
    }


    public List<Comment> findChildComments(Integer parentCommentId) {
        return commentMapper.selectChildComments(parentCommentId);
    }

//    public Integer findChildCommentNum(Integer parentCommentId) {
//        return commentMapper.selectChildCommentNum(parentCommentId);
//    }

    public Integer updateLike(Comment comment) {
        return commentMapper.updateLikeNum(comment);
    }

}
